
cc.Class({
    extends: cc.Component,

    properties: {
        speed:1,
        topshow : {
            default:null,
            type:cc.Node,
        },
    },

    

    onLoad :function () {
        var topshow = this.topshow 
        this.node.on(cc.Node.EventType.TOUCH_START,function(e){
            if(topshow.childrenCount > 0) {
                for(var i = topshow.childrenCount - 1; i >= 0; i--) {
                    topshow.children[i].destroy();
                }
            }
        },this)
        this.node.on(cc.Node.EventType.TOUCH_MOVE,function(e){
            var lx  =e.getDeltaX();
            var ly =  e.getDeltaY();
            cc.log("lx=",lx,"ly=",ly)
            

            var x = this.node.x
            var y = this.node.y
            cc.log("x=",x,"y=",y)
           
            if(x+lx*this.speed < 1024 && x+lx*this.speed > -1024) {
                this.node.x = x+lx*this.speed
            }
            if(y+ly*this.speed <48.907 && y+ly*this.speed > -720) {
                this.node.y = y+ly*this.speed
            }
            
            
        },this)
        this.node.on(cc.Node.EventType.TOUCH_END,function(e){
            
        },this)
        this.node.on(cc.Node.EventType.TOUCH_CANCEL,function(e){
            
        },this)
    },

    start () {

    },

    update (dt) {},
});
